<%= form_for(@user) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

      <ul>
      <% @user.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :username, "Username" %><br />
    <%= f.text_field :username %>
  </div>
  <div class="field">
    <%= f.label :rpassword, "Password" %><br />
    <%= password_field :user, :rpassword %>
  </div>
  <div class="field">
    <%= f.label :name, "Name" %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :email, "Email" %><br />
    <%= f.text_field :email %>
  </div>
<% if @current_user and @current_user.is_admin %>
  <div class="field">
    <%= f.label :is_admin %><br />
    <%= f.check_box :is_admin %>
  </div>
<% else %>
  <div class="field">
    <%= f.hidden_field :is_admin, :value => false %>
  </div>
<% end %>
  <div class="field">
    <%= f.hidden_field :is_active, :value => true %>
  </div>
  <div class="actions">
    <button id="user_submit" name="commit" type="submit"><%= @current_user ? "Submit" : "Sign Up!" %></button>
  </div>
<% end %>
